{include file="public_head" /}

<!-- datatables -->
<link href="__STATIC__/js/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- chk_3 -->
<link href="__STATIC__/css/chk_3.css" rel="stylesheet" type="text/css"/>

<body class="nav-md">

<div class="container body">


    <div class="main_container">

        {include file="public_sidebar,public_nav" /}

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3>

                        </h3>
                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="row">

                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>查看业绩</h2>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <form name="form" id="form" method="get" action="">
                                    <div class="title_left">
                                        <div class="col-md-{eq name='$auding_status' value="2"}11{else/}9{/eq} col-sm-3 col-xs-12 form-group pull-left top_search">
                                        <!--<div class="input-group" style="float: left;margin: 0 20px;">-->

                                        <!--<select name="way" class="select2_single" style="width: 200px;"-->
                                        <!--tabindex="-1">-->
                                        <!--<option value="0">- 请选择支付状态 -</option>-->
                                        <!--<option value="未支付" {eq name=':input("way")' value='未支付' }selected{/eq}>未支付</option>-->
                                        <!--<option value="余额支付" {eq name=':input("way")' value='余额支付' }selected{/eq}>余额支付</option>-->
                                        <!--<option value="支付宝" {eq name=':input("way")' value='支付宝' }selected{/eq}>支付宝</option>-->
                                        <!--<option value="微信" {eq name=':input("way")' value='微信' }selected{/eq}>微信</option>-->
                                        <!--<option value="退款" {eq name=':input("way")' value='退款' }selected{/eq}>退款</option>-->
                                        <!--</select>-->
                                        <!--</div>-->
                                        <div class="input-group" style="float: left;margin: 0 20px;">

                                            <select name="order_type" id="status1" class="select2_single" style="width: 200px;"
                                                    tabindex="-1">
                                                <option value="0">- 订单类型 -</option>

                                                <option value="1" {eq name=':input("order_type")' value='1' }selected{/eq}>商品订单</option>
                                                <option value="2" {eq name=':input("order_type")' value='2' }selected{/eq}>服务订单</option>
                                                <option value="3" {eq name=':input("order_type")' value='3' }selected{/eq}>礼包订单</option>

                                            </select>
                                        </div>
                                        <div class="input-group" style="float: left;margin: 0 20px;">

                                            <select name="card_type" id="status124" class="select2_single" style="width: 200px;"
                                                    tabindex="-1">
                                                <option value="0">- 礼包订单类型 -</option>

                                                <option value="1" {eq name=':input("card_type")' value='1' }selected{/eq}>礼包</option>
                                                <option value="2" {eq name=':input("card_type")' value='2' }selected{/eq}>实体卡</option>


                                            </select>
                                        </div>
                                        <div class="input-group" style="float: left;margin: 0 20px;">

                                            <select name="type" id="status1" class="select2_single" style="width: 200px;"
                                                    tabindex="-1">
                                                <option value="0">- 提成类型 -</option>

                                                <option value="1" {eq name=':input("type")' value='1' }selected{/eq}>服务提成</option>
                                                <option value="2" {eq name=':input("type")' value='2' }selected{/eq}>销售提成</option>

                                            </select>
                                        </div>
                                        {eq name=":session('auding_status')" value="2"}
                                        <div class="input-group" style="float: left;margin: 0 20px;">

                                            <select name="shop_id" id="status1" class="select2_single" style="width: 200px;"
                                                    tabindex="-1">
                                                <option value="0">- 全部门店 -</option>
                                                {volist name=":db('shop')->where('auding_status',2)->where('is_delete',1)->select()" id="vo"}
                                                <option value="{$vo.id}" {eq name=':input("shop_id")' value='$vo.id' }selected{/eq}>{$vo.shop_title}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                        {/eq}
                                        <div class="input-group" style="float: left;margin: 0 20px;" id="mendianren">

                                            <select name="assignor_id" id="status" class="select2_single" style="width: 200px;" tabindex="-1">
                                                <option value="0">- 全部人员 -</option>
                                                {volist name="$shop_assignor" id="vo"}
                                                <option value="{$vo.id}" {eq name=':input("assignor_id")' value='$vo.id' }selected{/eq}>{$vo.name}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                        <div class="input-group" style="float: left;margin: 0 20px;">
                                            <input type="text" class="form-control" name="interval_timer"
                                                   id="interval_timer"
                                                   style="width: 200px;"
                                                   placeholder="请选择时间区间..." value="{:input('interval_timer')}">
                                        </div>
                                        <div class="input-group" style="float: left;margin: 0 20px;" id="mendianren">

                                            <select name="is_agree" id="status" class="select2_single" style="width: 200px;" tabindex="-1">
                                                <option value="0">- 是否同意 -</option>

                                                <option value="1" {eq name=':input("is_agree")' value='1' }selected{/eq}>未同意</option>
                                                <option value="2" {eq name=':input("is_agree")' value='2' }selected{/eq}>已同意</option>
                                                <option value="3" {eq name=':input("is_agree")' value='3' }selected{/eq}>未设置门店人员</option>

                                            </select>
                                        </div>

                                        <div class="input-group" style="float: left;margin: 0 20px;">
                                            <input type="text" class="form-control" name="title"

                                                   placeholder="请输入订单号..." value="{:input('title')}">
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-primary" style="margin-left: 10px;">搜 索</button>
                            </div>
                                    <table style="border-bottom:1px solid #ddd;"
                                           class="table table-striped table-bordered table-hover">
                                        <thead>
                                        <tr class="success">
                                            <!--<th style="width: 2%; padding: 10px;">-->
                                                <!--<input type="checkbox" class="checkall"-->
                                                       <!--onclick="CheckAll(this.checked);"/>-->
                                            <!--</th>-->
                                            <!--<th>排序</th>-->
                                            <th width="">订单ID</th>
                                            <th width="">门店名称</th>
                                            <th width="">订单号</th>
                                            <th width="">用户账号</th>
                                            <th width="">订单车牌号</th>
                                            <th width="">订单类型</th>
                                            <th width="">实体卡卡号</th>
                                            <th width="">提成类型</th>
                                            <th width="">服务人员</th>
                                            <th width="">服务金额</th>
                                            <th width="">服务分类</th>
                                            <th width="">服务内容</th>
                                            <th width="">订单总金额</th>
                                            <th width="">是否同意</th>
                                            <th>下单时间</th>
                                            <th width="">服务时间</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {empty name="data"}
                                            <tr><td colspan="12"><div style='font-size:24px;margin:30px 0;'>没有找到记录</div></td></tr>
                                        {/empty}
                                        {volist name="data" id="item" key="k"}
                                        <tr >
                                            <td>{$item.order_id}</td>
                                            <td>{$item.shop_title}</td>
                                            <td>{$item.order_number}</td>
                                            <td>{$item.username}</td>
                                            <td>{$item.car_number}</td>
                                            <td>{switch item.order_type}
                                                {case 1}商品订单{/case}
                                                {case 2}服务订单{/case}
                                                {case 3}礼包订单{/case}
                                                {default /}无
                                                {/switch}
                                                {switch item.card_type}
                                                {case 1}(礼包){/case}
                                                {case 2}(实体卡){/case}
                                                {default /}
                                                {/switch}
                                            </td>
                                            <td>{$item.card_num}</td>
                                            <td>{$item.type}</td>
                                            <td>{$item.name}</td>
                                            <td>{$item.assignor_price}</td>
                                            <td>{$item.assignor_id}</td>
                                            <td>{$item.assignor_content}</td>
                                            <td>{$item.amount}</td>
                                            <td>{$item.is_agree}</td>
                                            <td>{$item.create_time}</td>
                                            <td>{$item.sc}</td>
                                        </tr>
                                        {/volist}
                                        </tbody>
                                    </table>
                                    <div style="float: right;margin-top: -30px;">{$data->render()}</div>
                            <button type="button" class="btn btn-success" style="margin-top: 20px;" onClick="dc()">记录数：{$order_count}条</button>
                            <button type="button" class="btn btn-danger" style="margin-top: 20px;" onClick="dc()">提成总金额：{$order_sum}元</button>
                            <button type="button" class="btn btn-info" style="margin-top: 20px;" onClick="dc({:input('coupon_id')})">门店人员业绩导出</button>
                            <button type="button" class="btn btn-danger" style="margin-top: 20px;" onClick="dc()">订单总金额：{$order_amount}元</button>
                            </form>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

        </div>
        <!-- /page content -->
    </div>

</div>

{include file="public_foot" /}
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>
<!-- public -->
<script src="__STATIC__/js/public.js"></script>
<!-- layer -->
<script src="__STATIC__/js/layer.js"></script>
<script type="text/javascript">
    // list
    $(document).ready(function () {
        // select2
        $('[name="shop_id"]').change(function(){
            var shop_id = $(this).val();
            $.ajax({
                url : '{:url("shopAssignor")}',
                data:{'shop_id':shop_id},
                dataType:'json',
                success:function(data){
                    console.log(data);
                    var str = '<select name="assignor_id" id="status" class="select2_single form-control" tabindex="-1" style="width: 200px;">\n';
                    str += '<option value="0">- 门店全部人员 -</option>';
                    $.each(data, function(k,v){
                        str += '<option value="'+v.id+'">'+v.name+'</option>\n';
                    });
                    str +='</select>\n';
                    console.log(str);
                    $('#mendianren').html(str);
                    $(".select2_single").select2({
                        placeholder: "请选择分类",
                        allowClear: true
                    });


                }
            });



        });

        $(".select2_single1").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        // interval_timer
        $('#interval_timer').daterangepicker(null,
            function(start, end, label) {
//                console.log(start.toISOString(), end.toISOString(), label);
            });
    });


    //导出excel表格
    function dc(){
        var assignor_id = {:input('assignor_id',0)};
        var order_type = {:input('order_type',0)};
        var is_agree = {:input('is_agree',0)};
        var shop_id = {:input('shop_id',0)};
		
        var title = "{:input('title')}";
        var type = "{:input('type')}";
        var both = "{:input('interval_timer')}";
        var title = "{:input('title')}";
        var card_type = "{:input('card_type')}";
        var both_arr = both.split("/");
      
        if (both_arr[0] == both_arr[1]) {
            layer.msg('请选择时间区间为同1天!');
            return;
        }
		console.log(shop_id);
        window.location.href = "{:url('daochu')}?assignor_id="+assignor_id+'&title='+title+'&interval_timer='+both+'&shop_id='+shop_id+'&is_agree='+is_agree+'&order_type='+order_type+'&type='+type+'&card_type='+card_type;
    }
    $(".select2_single").select2({
        placeholder: "请选择快递公司",
        allowClear: true
    });
</script>
